package com.efuture.io;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @ClassNAME BufferedOutputStreamTest
 * @Description BufferedOutputStream的使用
 * @Author zhaoshanshan
 * @Date 2021/9/8 8:48 下午
 * @Version 1.0
 */
public class BufferedOutputStreamTest {

    public static void main(String[] args) {
        BufferedOutputStream bos = null;
        try{
            bos = new BufferedOutputStream(new FileOutputStream("javasestudy/src/com.efuture.io/TestFileFour.txt"));
            String s = "好好学习,天天向上";
            byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
            bos.write(bytes);
            bos.flush();
        }catch (Exception e){
            e.getStackTrace();
        }finally {
            if(null!=bos){
                try {
                    bos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}